package com.saltedfish.tool.util

import java.text.ParseException
import java.text.SimpleDateFormat
import java.util.*

class TimeUtils {
    companion object {
        fun getTime(timeString: String?): Long? {
            val sdf = SimpleDateFormat("yyyy-MM-dd hh:mm")
            val d: Date
            var l = 0L as Long
            try {
                d = sdf.parse(timeString)
                l = (d.time / 1000)
            } catch (e: ParseException) {
                e.printStackTrace()
            }
            return l
        }
        fun getNowTime(): Long?{
            //获得系统的时间，单位为毫秒,转换为妙
            val totalMilliSeconds = System.currentTimeMillis()
            return totalMilliSeconds / 1000
        }
        fun getWeek():String?{
            val cal = Calendar.getInstance()
            val i = cal[Calendar.DAY_OF_WEEK]
            if(i==1){
                return "7"
            }else{
                return (i-1).toString()
            }

        }
    }
}